package lesson6;

public class Demo1 {
    public static void main(String[] args) {
        byte a = -5; //10000101     11111010     11111101     10000011
        //<<有符号左移
//        System.out.println(a<<1);
//        System.out.println(a<<2);
//        System.out.println(a<<3);
//        System.out.println(a>>1);
//        System.out.println(a>>2);
//        System.out.println(a>>3);
//
//        byte b = 7;   //00000111
//        System.out.println(b<<6);
        //byte b = a<<2;
        //10000000 00000000 00000000 00000101
        //11111111 11111111 11111111 11111010
        //11111111 11111111 11111111 11111011
        //左移两位
        //11111111 11111111 11111111 11101100
        //10000000 00000000 00000000 00010011
        //10000000 00000000 00000000 00010100
        System.out.println(-5<<2);
        //右移两位
        //11111111 11111111 11111111 11111110
        //10000000 00000000 00000000 00000001
        //10000000 00000000 00000000 00000010
        System.out.println(-5>>2);


        byte aa = 127;
        //00000000 00000000 00000000 01111111
        System.out.println(aa<<24);

        //无符号右移 2,147,483,647
        System.out.println(-1>>>1);
        //10000000 00000000 00000000 00000001
        //11111111 11111111 11111111 11111110
        //01111111 11111111 11111111 11111111
        //有符号右移
        //System.out.println(-1>>1);


        //11111111 11111111 11111111 11111110
        System.out.println(-5>>3);
        System.out.println(-5>>100);
    }
}
